package com.pwt.controller.basicsetting;

import com.pwt.common.CustomException;
import com.pwt.entity.CpConfig;
import com.pwt.entity.Hierarchy;
import com.pwt.model.HierarchyConfigModel;
import com.pwt.service.HierarchyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author dw
 * @date 2022/1/5 13:55
 * @Description
 */
@RestController
@Tag(name = "产线配置")
public class HierarchyConfigController {

    private HierarchyService hierarchyService;

    public HierarchyConfigController(HierarchyService hierarchyService) {
        this.hierarchyService = hierarchyService;
    }

    @PostMapping("/hierarchy")
    @Operation(description = "层级配置",summary = "层级配置")
    public void updateHierarchy(@RequestBody @Validated List<Hierarchy> list) throws CustomException {
        this.hierarchyService.updateHierarchy(list);
    };

    @GetMapping("/hierarchy")
    @Operation(description = "获取层级配置集合",summary = "获取层级配置集合")
    public HierarchyConfigModel queryHierarchyConfig() throws CustomException {
        return this.hierarchyService.queryHierarchy();
    };

}
